﻿using EFCore.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SIService;
using SService;

namespace WMSWeb.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PurchaseordersController : ControllerBase
    {
        private readonly WmssystemContext myDb;
        private readonly PurchaseordersS purchaseordersS;

        public PurchaseordersController(WmssystemContext myDb, SService.PurchaseordersS purchaseordersS)
        {
            this.myDb = myDb;
            this.purchaseordersS = purchaseordersS;
        }
        /// <summary>
        /// 4个条件分页查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PO_Purchaseorders>> Fye(int pageSize, int currentPage, string Number = null, string Status = null, string Supplier = null, DateTime? date = null, DateTime? date1 = null)
        {
            return await purchaseordersS.Fye(pageSize, currentPage, Number, Status, Supplier, date, date1);
        }
        [HttpGet]
        public async Task<List<PO_Purchaseorders>> Qu()
        {
            return await purchaseordersS.Qu();
        }
        /// <summary>
        /// 进货订单新增
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> JhAdd(PO_Purchaseorders pO_Purchaseorders)
        {
            return await purchaseordersS.JhAdd(pO_Purchaseorders);
        }
        /// <summary>
        /// 进货订单批量删除
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpDelete]
        public async Task<int> JhDel(List<int> Ids)
        {
            return await purchaseordersS.JhDel(Ids);
        }
        /// <summary>
        /// 进货订单修改
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<int> JhUpd(PO_Purchaseorders pO_Purchaseorders)
        {
            return await purchaseordersS.JhUpd(pO_Purchaseorders);
        }
        /// <summary>
        /// 进货订单审核
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<int> JhShen(PO_Purchaseorders pO_Purchaseorders, string to)
        {
            return await purchaseordersS.JhShen(pO_Purchaseorders, to);
        }
    }
}
